var status = -1;
var selectionLog = [];
var items = [1372180, 1372181, 1312156, 1312157, 1332228, 1332229, 1302279, 1302278, 1012377, 1222066, 1462196, 1462197, 1442226, 1442227, 1522098, 1452208, 1522097, 1452209, 1482172, 1422143, 1232062, 1482171, 1232061, 1212067, 1212071, 1362093, 1362094, 1222062, 1412139, 1412138, 1492182, 1242066, 1492183, 1242067, 1322206, 1322207, 1472218, 1402200, 1582038, 1472217, 1402202, 1382213, 1382212, 1532102, 1532101, 1132229, 1052613, 1422144, 1003864, 1122253, 1282034, 1272035, 1102563, 1432171, 1432170];

function start() {
    action(1, 0, 0)
}

function action(e, c, b) {
    if (im.getServerName().equals("BMS单机") && im.getServerName().equals("BMS至尊体验服") && !im.getServerName().equals("BMS至尊")) {
        im.playerMessage(1, " 使用环境异常，请还原服务端配置。 ");
        im.dispose();
        return
    }
    if (status == 0 && e == 0) {
        im.dispose();
        return
    }(e == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var d = "想要兑换哪一件武器？\r\n#b";
            for (var a = 0; a < items.length; a++) {
                d += "#L" + a + "##i" + items[a] + "##z" + items[a] + "##l\r\n"
            }
            im.askMenu(d)
        } else {
            if (status === a++) {
                im.dispose();
                var f = im.getItemId();
                im.gainItem(items[b], 1);
                im.gainItem(f, -1)
            }
        }
    }
};